package com.design.graduation.asdemo.view;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.design.graduation.asdemo.R;
import com.design.graduation.asdemo.model.ImageRecycle;
import com.design.graduation.asdemo.model.SolicitingDetails;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lijinyuan on 16/2/28.
 */
public class ImageRecycleViewAdapter extends RecyclerView.Adapter {


    private LayoutInflater mLayoutInflater;
    private Context mContext;
    private List<ImageRecycle> mList;

    public ImageRecycleViewAdapter(Context context, List list) {
        this.mContext = context;
        this.mList = list;
        mLayoutInflater = LayoutInflater.from(context);
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ContentHolder(mLayoutInflater.inflate(R.layout.item_image, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        if (holder instanceof ContentHolder) {

            ((ContentHolder) holder).mImage.setImageResource(mList.get(position).getImg());
        }
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }


    public class ContentHolder extends RecyclerView.ViewHolder {
        ImageView mImage = (ImageView) itemView.findViewById(R.id.item_img);

        ContentHolder(View view) {
            super(view);
            mImage = (ImageView) view.findViewById(R.id.item_img);
        }
    }
}
